load("//bazel:mongo_src_rules.bzl", "idl_generator", "mongo_cc_library", "mongo_cc_unit_test")

package(default_visibility = ["//visibility:public"])

exports_files(
    glob([
        "*.h",
        "*.cpp",
    ]),
)

idl_generator(
    name = "test_commands_enabled_gen",
    src = "test_commands_enabled.idl",
)

mongo_cc_library(
    name = "test_commands_enabled",
    srcs = [
        "test_commands_enabled.cpp",
        ":test_commands_enabled_gen",
    ],
    deps = [
        "//src/mongo/db:server_base",
    ],
)

idl_generator(
    name = "buildinfo_common_gen",
    src = "buildinfo_common.idl",
    deps = [
        "//src/mongo/idl:generic_argument_gen",
        "//src/mongo/util:buildinfo_gen",
    ],
)

mongo_cc_library(
    name = "buildinfo_common",
    srcs = [
        "buildinfo_common.cpp",
        ":buildinfo_common_gen",
    ],
    deps = [
        "//src/mongo:base",
        "//src/mongo/db:commands",
        "//src/mongo/db:server_base",
        "//src/mongo/db/auth",
        "//src/mongo/executor:async_request_executor",
        "//src/mongo/util:buildinfo",
    ],
)

idl_generator(
    name = "set_feature_compatibility_version_gen",
    src = "set_feature_compatibility_version.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "fle2_cleanup_gen",
    src = "fle2_cleanup.idl",
    deps = [
        "//src/mongo/crypto:fle_stats_gen",
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "fle2_compact_gen",
    src = "fle2_compact.idl",
    deps = [
        "//src/mongo/crypto:fle_field_schema_gen",
        "//src/mongo/crypto:fle_stats_gen",
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "generic_gen",
    src = "generic.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "parameters_gen",
    src = "parameters.idl",
)

idl_generator(
    name = "shardsvr_run_search_index_command_gen",
    src = "shardsvr_run_search_index_command.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/db/query/search:search_query_view_spec_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

mongo_cc_library(
    name = "shardsvr_run_search_index_command_idl",
    srcs = [
        ":shardsvr_run_search_index_command_gen",
    ],
    deps = [
        "//src/mongo:base",
        "//src/mongo/db/query/search:search_index_common",
        "//src/mongo/db/repl:read_concern_args",
        "//src/mongo/db/shard_role/lock_manager:flow_control_ticketholder",
        "//src/mongo/idl:idl_parser",
    ],
)

idl_generator(
    name = "shardsvr_resolve_view_command_gen",
    src = "shardsvr_resolve_view_command.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "sessions_commands_gen",
    src = "sessions_commands.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/db/auth:access_checks_gen",
        "//src/mongo/db/session:logical_session_id_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "xray_commands_gen",
    src = "xray_commands.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "connection_status_gen",
    src = "connection_status.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/db/auth:auth_types_gen",
        "//src/mongo/db/auth:parsed_privilege_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "drop_connections_gen",
    src = "drop_connections.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
        "//src/mongo/util/net:hostandport_gen",
    ],
)

idl_generator(
    name = "generic_servers_gen",
    src = "generic_servers.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "internal_transactions_test_command_gen",
    src = "internal_transactions_test_command.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "rotate_certificates_gen",
    src = "rotate_certificates.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "user_management_commands_gen",
    src = "user_management_commands.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/db:multitenancy_gen",
        "//src/mongo/db/auth:address_restriction_gen",
        "//src/mongo/db/auth:auth_types_gen",
        "//src/mongo/db/auth:parsed_privilege_gen",
        "//src/mongo/db/auth:user_management_commands_parser_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "rwc_defaults_commands_gen",
    src = "rwc_defaults_commands.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/db:read_write_concern_defaults_gen",
        "//src/mongo/db:write_concern_options_gen",
        "//src/mongo/db/repl:read_concern_args_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

mongo_cc_library(
    name = "rwc_defaults_commands",
    srcs = [
        ":rwc_defaults_commands_gen",
    ],
    deps = [
        "//src/mongo/db:read_write_concern_defaults",
        "//src/mongo/db:server_base",
    ],
)

idl_generator(
    name = "authentication_commands_gen",
    src = "authentication_commands.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

mongo_cc_library(
    name = "authentication_commands",
    srcs = [
        "authentication_commands.cpp",
        "authentication_commands_gen",
    ],
    deps = [
        # TODO SERVER-78809 - remove dependencies
        "//src/mongo/db/auth",
        "//src/mongo/db/auth:auth_options",
        "//src/mongo/db/auth:authentication_session",
        "//src/mongo/db/auth:authorization_manager_global",
        "//src/mongo/db/auth:cluster_auth_mode",
        "//src/mongo/db/auth:sasl_commands",
        "//src/mongo/db:commands",
        "//src/mongo/db/exec/mutable_bson",
        "//src/mongo/db:server_base",
        "//src/mongo/rpc:client_metadata",
        "//src/mongo/util/net:ssl_manager",
        ":test_commands_enabled",
    ] + select({
        "//bazel/config:ssl_enabled": [
            "//src/mongo/db/auth:user_request_x509",
        ],
        "//conditions:default": [],
    }),
)

idl_generator(
    name = "feature_compatibility_version_gen",
    src = "feature_compatibility_version.idl",
)

mongo_cc_library(
    name = "create_command",
    srcs = [
        "//src/mongo/db/shard_role/ddl:create_gen",
    ],
    deps = [
        "//src/mongo/crypto:encrypted_field_config",
        "//src/mongo/db:server_base",
        "//src/mongo/db:server_options",
        "//src/mongo/db/auth:authprivilege",
        "//src/mongo/db/query:query_knobs",
        "//src/mongo/db/shard_role/shard_catalog:collection_options",
        "//src/mongo/db/timeseries:timeseries_options",
    ],
)

idl_generator(
    name = "fsync_gen",
    src = "fsync.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "http_client_gen",
    src = "http_client.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "sysprofile_gen",
    src = "sysprofile.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "set_index_commit_quorum_gen",
    src = "set_index_commit_quorum.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/db/index_builds:commit_quorum_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "shutdown_gen",
    src = "shutdown.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "compact_gen",
    src = "compact.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/db/auth:action_type_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "resize_oplog_gen",
    src = "resize_oplog.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "vote_index_build_gen",
    src = "vote_index_build.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
        "//src/mongo/util/net:hostandport_gen",
    ],
)

idl_generator(
    name = "kill_operations_gen",
    src = "kill_operations.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "profile_gen",
    src = "profile.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "txn_cmds_gen",
    src = "txn_cmds.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/db/sharding_environment:sharding_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "txn_two_phase_commit_cmds_gen",
    src = "txn_two_phase_commit_cmds.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/db/sharding_environment:sharding_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

idl_generator(
    name = "fle2_get_count_info_command_gen",
    src = "fle2_get_count_info_command.idl",
    deps = [
        "//src/mongo/crypto:fle_stats_gen",
        "//src/mongo/db:basic_types_gen",
        "//src/mongo/idl:generic_argument_gen",
    ],
)

mongo_cc_library(
    name = "list_collections_filter",
    srcs = [
        "//src/mongo/db/shard_role/ddl:list_collections_filter.cpp",
    ],
    deps = [
        "//src/mongo:base",
    ],
)

mongo_cc_library(
    name = "umc_commands_idl",
    srcs = [
        ":user_management_commands_gen",
    ],
    deps = [
        "//src/mongo/db:common",
        "//src/mongo/db:server_base",
        "//src/mongo/db/auth:address_restriction",
        "//src/mongo/db/auth:authprivilege",
        "//src/mongo/db/auth:role_name_or_string",
    ],
)

mongo_cc_library(
    name = "set_feature_compatibility_version_idl",
    srcs = [
        ":set_feature_compatibility_version_gen",
    ],
    deps = [
        "//src/mongo/db:server_base",
    ],
)

mongo_cc_library(
    name = "list_databases_command",
    srcs = [
        "//src/mongo/db/shard_role/ddl:list_databases_gen",
    ],
    deps = [
        "//src/mongo/db:commands",
        "//src/mongo/db:server_base",
        "//src/mongo/db/auth:authprivilege",
    ],
)

mongo_cc_library(
    name = "list_databases_for_all_tenants_command",
    srcs = [
        "//src/mongo/db/shard_role/ddl:list_databases_for_all_tenants_gen",
    ],
    deps = [
        "//src/mongo/db:server_base",
        "//src/mongo/db/auth:authprivilege",
    ],
)

mongo_cc_library(
    name = "txn_cmd_request",
    srcs = [
        ":txn_cmds_gen",
        ":txn_two_phase_commit_cmds_gen",
    ],
    deps = [
        "//src/mongo/db:commands",
        "//src/mongo/db:server_base",
        "//src/mongo/db/auth:authprivilege",
    ],
)

mongo_cc_library(
    name = "shutdown_idl",
    srcs = [
        "shutdown.cpp",
        "shutdown_gen",
    ],
    deps = [
        "//src/mongo/bson:bson_validate",
        "//src/mongo/db:server_base",
        "//src/mongo/db:service_context",
    ],
)

mongo_cc_library(
    name = "profile_common",
    srcs = [
        "profile_common.cpp",
        "set_profiling_filter_globally_cmd.cpp",
        ":profile_gen",
        "//src/mongo/db:profile_filter_impl.cpp",
    ],
    deps = [
        "//src/mongo/db:commands",
        "//src/mongo/db:profile_settings",
        "//src/mongo/db:query_expressions",
        "//src/mongo/db:query_matcher",
        "//src/mongo/db:server_base",
        "//src/mongo/db:shard_role_api",
        "//src/mongo/db/auth",
        "//src/mongo/db/auth:authprivilege",
        "//src/mongo/db/query/compiler/dependency_analysis",
        "//src/mongo/db/query/query_stats",
    ],
)

mongo_cc_library(
    name = "profile_cmd_test_utils",
    srcs = [
        "profile_cmd_test_utils.cpp",
    ],
    deps = [
        ":profile_common",
        "//src/mongo/unittest",
    ],
)

mongo_cc_library(
    name = "mongod_fcv",
    srcs = [
        "feature_compatibility_version.cpp",
        ":feature_compatibility_version_gen",
    ],
    deps = [
        "//src/mongo/db:commands",
        "//src/mongo/db:dbdirectclient",
        "//src/mongo/db:server_base",
        "//src/mongo/db/repl:repl_coordinator_interface",
        "//src/mongo/db/repl:repl_server_parameters",
        "//src/mongo/db/repl:repl_settings",
        "//src/mongo/db/shard_role",
        "//src/mongo/db/shard_role/shard_catalog:collection_options",
        "//src/mongo/db/storage:storage_options",
    ],
)

mongo_cc_library(
    name = "mongod_fsync",
    srcs = [
        "fsync.cpp",
        ":fsync_gen",
    ],
    deps = [
        "//src/mongo/db:commands",
        "//src/mongo/db:dbdirectclient",
        "//src/mongo/db/auth",
        "//src/mongo/db/auth:authprivilege",
        "//src/mongo/db/query/query_stats",
        "//src/mongo/db/shard_role/lock_manager",
        "//src/mongo/db/shard_role/lock_manager:exception_util",
        "//src/mongo/db/storage:backup_cursor_hooks",
        "//src/mongo/util:background_job",
        "//src/mongo/util/concurrency:spin_lock",
    ],
)

mongo_cc_library(
    name = "set_index_commit_quorum_idl",
    srcs = [
        ":set_index_commit_quorum_gen",
    ],
    deps = [
        "//src/mongo/db:rw_concern_d",
        "//src/mongo/db/index_builds:commit_quorum_options",
        "//src/mongo/idl:idl_parser",
    ],
)

# Commands available in every process that executes commands
mongo_cc_library(
    name = "core",
    srcs = [
        "end_sessions_command.cpp",
        "fail_point_cmd.cpp",
        "fle2_compact.cpp",
        "generic.cpp",
        "hashcmd.cpp",
        "kill_all_sessions_by_pattern_command.cpp",
        "kill_all_sessions_command.cpp",
        "kill_sessions_command.cpp",
        "parameters.cpp",
        "parse_log_component_settings.cpp",
        "refresh_logical_session_cache_now.cpp",
        "refresh_sessions_command.cpp",
        "shardsvr_resolve_view_command.cpp",
        "shardsvr_run_search_index_command.cpp",
        "start_session_command.cpp",
        ":fle2_cleanup_gen",
        ":fle2_compact_gen",
        ":generic_gen",
        ":parameters_gen",
        ":sessions_commands_gen",
        ":shardsvr_resolve_view_command_gen",
        "//src/mongo/db/commands/server_status:server_status_command.cpp",
        "//src/mongo/db/shard_role/ddl:rename_collection_common.cpp",
    ],
    deps = [
        ":shardsvr_run_search_index_command_idl",
        ":test_commands_enabled",
        "//src/mongo/crypto:encrypted_field_config",
        "//src/mongo/crypto:fle_crypto",
        "//src/mongo/db:commands",
        "//src/mongo/db:common",
        "//src/mongo/db:dbdirectclient",
        "//src/mongo/db:fle_crud",
        "//src/mongo/db:mongohasher",
        "//src/mongo/db:server_base",
        "//src/mongo/db/auth",
        "//src/mongo/db/auth:authprivilege",
        "//src/mongo/db/commands/query_cmd:update_metrics",
        "//src/mongo/db/commands/query_cmd:write_commands_common",
        "//src/mongo/db/commands/server_status:server_status_core",
        "//src/mongo/db/exec/mutable_bson",
        "//src/mongo/db/pipeline:lite_parsed_document_source",
        "//src/mongo/db/query/search:search_index_options",
        "//src/mongo/db/query/write_ops:write_ops_parsers",
        "//src/mongo/db/session:kill_sessions",
        "//src/mongo/db/session:logical_session_cache",
        "//src/mongo/db/session:logical_session_id_helpers",
        "//src/mongo/db/stats:counters",
        "//src/mongo/db/transaction:transaction_api",
        "//src/mongo/db/views:view_catalog_helpers",
        "//src/mongo/executor:async_multicaster",
        "//src/mongo/logv2:logv2_options",
        "//src/mongo/rpc:message",
        "//src/mongo/util/net:http_client",
    ],
)

mongo_cc_library(
    name = "cluster_server_parameter_commands_invocation",
    srcs = [
        "//src/mongo/db/topology/cluster_parameters:get_cluster_parameter_invocation.cpp",
        "//src/mongo/db/topology/cluster_parameters:set_cluster_parameter_invocation.cpp",
    ],
    deps = [
        "//src/mongo:base",
        "//src/mongo/db:audit",
        "//src/mongo/db:server_base",
        "//src/mongo/db/query/query_settings:query_settings_service",
        "//src/mongo/db/topology/cluster_parameters:cluster_server_parameter_cmds_idl",
        "//src/mongo/s:sharding_api",
    ],
)

mongo_cc_library(
    name = "set_cluster_parameter_impl",
    srcs = [
        "//src/mongo/db/topology/cluster_parameters:set_cluster_parameter_replset_impl.cpp",
    ],
    deps = [
        ":cluster_server_parameter_commands_invocation",
        ":mongod_fcv",
        "//src/mongo/db:dbdirectclient",
        "//src/mongo/db:server_feature_flags",
        "//src/mongo/db/query/query_settings:query_settings_service_dependencies",
    ],
)

mongo_cc_library(
    name = "dbcheck_command",
    srcs = [
        "dbcheck_command.cpp",
    ],
    deps = [
        "//src/mongo/db:dbhelpers",
        "//src/mongo/db:query_exec",
        "//src/mongo/db:record_id_helpers",
        "//src/mongo/db:rw_concern_d",
        "//src/mongo/db:server_base",
        "//src/mongo/db:throttle_cursor",
        "//src/mongo/db/repl:oplog",
        "//src/mongo/db/repl:repl_server_parameters",
        "//src/mongo/db/repl/dbcheck",
        "//src/mongo/db/repl/dbcheck:health_log_interface",
        "//src/mongo/db/rss:replicated_storage_service",
        "//src/mongo/db/shard_role/lock_manager:exception_util",
        "//src/mongo/db/shard_role/shard_catalog:catalog_helpers",
        "//src/mongo/db/shard_role/shard_catalog:collection_options",
        "//src/mongo/util:md5",
        "//src/mongo/util:progress_meter",
    ],
)

mongo_cc_library(
    name = "test_commands",
    srcs = [
        "sysprofile.cpp",
        "test_commands.cpp",
        "whats_my_uri_cmd.cpp",
        ":sysprofile_gen",
    ],
    deps = [
        ":test_commands_enabled",
        "//src/mongo:base",
        "//src/mongo/db:commands",
        "//src/mongo/db:dbhelpers",
        "//src/mongo/db:query_exec",
        "//src/mongo/db/collection_crud",
        "//src/mongo/db/index_builds:index_builds_coordinator",
        "//src/mongo/db/query/write_ops",
        "//src/mongo/db/query/write_ops:write_ops_exec",
        "//src/mongo/db/shard_role",
        "//src/mongo/db/shard_role/shard_catalog:catalog_helpers",
    ],
)

mongo_cc_library(
    name = "kill_operations_idl",
    srcs = [
        ":kill_operations_gen",
    ],
    deps = [
        "//src/mongo/db:server_base",
    ],
)

mongo_cc_library(
    name = "kill_common",
    srcs = [
        "kill_op_cmd_base.cpp",
    ],
    deps = [
        ":kill_operations_idl",
        "//src/mongo/db:audit",
        "//src/mongo/db:commands",
        "//src/mongo/db:operation_killer",
        "//src/mongo/db/auth:authorization_manager_global",
        "//src/mongo/db/auth:authprivilege",
        "//src/mongo/db/query:command_request_response",
    ],
)

# Commands available in all mongodb server processes (mongod, mongos, etc.)
mongo_cc_library(
    name = "servers",
    srcs = [
        "conn_pool_stats.cpp",
        "conn_pool_sync.cpp",
        "connection_status.cpp",
        "cpuload.cpp",
        "drop_connections_command.cpp",
        "drop_connections_gen",
        "generic_servers.cpp",
        "isself.cpp",
        "reap_logical_session_cache_now.cpp",
        "rotate_certificates_command.cpp",
        "test_api_version_2_commands.cpp",
        "test_deprecation_command.cpp",
        "traffic_recording_cmds.cpp",
        "user_management_commands_common.cpp",
        ":connection_status_gen",
        ":generic_servers_gen",
        ":internal_transactions_test_command_gen",
        ":rotate_certificates_gen",
        "//src/mongo/db/commands/query_cmd:mr_common.cpp",
        "//src/mongo/db/commands/server_status:logical_session_server_status_section.cpp",
    ],
    srcs_select = [{
        "//bazel/config:xray_enabled": [
            "xray_commands.cpp",
            ":xray_commands_gen",
        ],
        "//conditions:default": [],
    }],
    deps = [
        ":authentication_commands",
        ":core",
        ":test_commands_enabled",
        ":umc_commands_idl",
        "//src/mongo/client:clientdriver_minimal",
        "//src/mongo/db:commands",
        "//src/mongo/db:common",
        "//src/mongo/db:log_process_details",
        "//src/mongo/db:multitenancy",
        "//src/mongo/db:read_write_concern_defaults",
        "//src/mongo/db:server_base",
        "//src/mongo/db:shared_request_handling",
        "//src/mongo/db:traffic_recorder",
        "//src/mongo/db/auth:address_restriction",
        "//src/mongo/db/commands/query_cmd:query_settings_cmds",
        "//src/mongo/db/pipeline",
        "//src/mongo/db/pipeline:change_stream_pipeline",
        "//src/mongo/db/pipeline:document_source_internal_apply_oplog_update",
        "//src/mongo/db/repl:isself",
        "//src/mongo/db/repl:repl_coordinator_interface",
        "//src/mongo/db/session:logical_session_cache",
        "//src/mongo/db/session:logical_session_id_helpers",
        "//src/mongo/db/session:session_catalog",
        "//src/mongo/executor:egress_connection_closer_manager",
        "//src/mongo/executor:task_executor_pool",
        "//src/mongo/rpc:client_metadata",
        "//src/mongo/scripting:scripting_common",
        "//src/mongo/transport:session_manager",
        "//src/mongo/util:ntservice",
        "//src/mongo/util/net:ssl_manager",
    ],
)

# Commands that are present in both mongod and embedded
mongo_cc_library(
    name = "standalone",
    srcs = [
        "create_indexes_cmd.cpp",
        "dbcommands.cpp",
        "fle2_get_count_info_command.cpp",
        "http_client.cpp",
        "http_client_gen",
        "kill_op.cpp",
        "killoperations_cmd.cpp",
        "sleep_command.cpp",
        "validate.cpp",
        "whats_my_sni_command.cpp",
        "//src/mongo/db/commands/query_cmd:acquire_locks.cpp",
        "//src/mongo/db/commands/query_cmd:aggregation_execution_state.cpp",
        "//src/mongo/db/commands/query_cmd:analyze_cmd.cpp",
        "//src/mongo/db/commands/query_cmd:count_cmd.cpp",
        "//src/mongo/db/commands/query_cmd:current_op.cpp",
        "//src/mongo/db/commands/query_cmd:distinct.cpp",
        "//src/mongo/db/commands/query_cmd:explain_cmd.cpp",
        "//src/mongo/db/commands/query_cmd:find_and_modify.cpp",
        "//src/mongo/db/commands/query_cmd:find_cmd.cpp",
        "//src/mongo/db/commands/query_cmd:getmore_cmd.cpp",
        "//src/mongo/db/commands/query_cmd:index_filter_commands.cpp",
        "//src/mongo/db/commands/query_cmd:killcursors_cmd.cpp",
        "//src/mongo/db/commands/query_cmd:pipeline_command.cpp",
        "//src/mongo/db/commands/query_cmd:plan_cache_clear_command.cpp",
        "//src/mongo/db/commands/query_cmd:plan_cache_commands.cpp",
        "//src/mongo/db/commands/query_cmd:run_aggregate.cpp",
        "//src/mongo/db/commands/query_cmd:write_commands.cpp",
        "//src/mongo/db/global_catalog/ddl:shuffle_list_command_results.cpp",
        "//src/mongo/db/shard_role/ddl:collmod_cmd.cpp",
        "//src/mongo/db/shard_role/ddl:create_command.cpp",
        "//src/mongo/db/shard_role/ddl:drop_indexes_cmd.cpp",
        "//src/mongo/db/shard_role/ddl:list_collections.cpp",
        "//src/mongo/db/shard_role/ddl:list_databases.cpp",
        "//src/mongo/db/shard_role/ddl:list_databases_for_all_tenants.cpp",
        "//src/mongo/db/shard_role/ddl:list_indexes.cpp",
        "//src/mongo/db/shard_role/ddl:rename_collection_cmd.cpp",
        "//src/mongo/db/shard_role/lock_manager:lock_info.cpp",
        "//src/mongo/db/shard_role/shard_catalog:validate_db_metadata_cmd.cpp",
    ],
    no_undefined_ref_DO_NOT_USE = False,
    deps = [
        "buildinfo_common",
        "core",
        "create_command",
        "kill_common",
        "list_collections_filter",
        "list_databases_command",
        "list_databases_for_all_tenants_command",
        "test_commands_enabled",
        "//src/mongo:base",
        "//src/mongo/crypto:encrypted_field_config",
        "//src/mongo/crypto:fle_crypto",
        "//src/mongo/db:api_parameters",
        "//src/mongo/db:change_stream_pre_images_collection_manager",
        "//src/mongo/db:command_can_run_here",
        "//src/mongo/db:commands",
        "//src/mongo/db:curop_failpoint_helpers",
        "//src/mongo/db:dbcommands_idl",
        "//src/mongo/db:fle_crud",
        "//src/mongo/db:fle_crud_mongod",
        "//src/mongo/db:index_key_validate",
        "//src/mongo/db:multitenancy",
        "//src/mongo/db:query_exec",
        "//src/mongo/db:rw_concern_d",
        "//src/mongo/db:server_base",
        "//src/mongo/db:server_feature_flags",
        "//src/mongo/db/commands/query_cmd:bulk_write_command",
        "//src/mongo/db/commands/query_cmd:current_op_common",
        "//src/mongo/db/commands/query_cmd:release_memory_cmd",
        "//src/mongo/db/commands/query_cmd:search_index_commands",
        "//src/mongo/db/index_builds:index_builds_coordinator",
        "//src/mongo/db/index_builds:multi_index_block",
        "//src/mongo/db/index_builds:two_phase_index_build_knobs_idl",
        "//src/mongo/db/memory_tracking",
        "//src/mongo/db/pipeline",
        "//src/mongo/db/pipeline:aggregation_request_helper",
        "//src/mongo/db/pipeline:desugarer",
        "//src/mongo/db/pipeline:docs_needed_bounds_visitor",
        "//src/mongo/db/pipeline/process_interface:mongo_process_interface",
        "//src/mongo/db/pipeline/process_interface:mongod_process_interfaces",
        "//src/mongo/db/query:collection_query_info",
        "//src/mongo/db/query:command_request_response",
        "//src/mongo/db/query:explain_diagnostic_printer",
        "//src/mongo/db/query:plan_yield_policy_release_memory",
        "//src/mongo/db/query:shard_key_diagnostic_printer",
        "//src/mongo/db/query/client_cursor:cursor_response_idl",
        "//src/mongo/db/query/compiler/stats",
        "//src/mongo/db/query/compiler/stats:stats_histograms",
        "//src/mongo/db/query/query_settings:query_settings_service",
        "//src/mongo/db/query/query_shape",
        "//src/mongo/db/query/query_stats",
        "//src/mongo/db/query/search:search_index_process_shard",
        "//src/mongo/db/query/stage_builder/sbe:query_sbe_abt",
        "//src/mongo/db/query/write_ops",
        "//src/mongo/db/query/write_ops:write_ops_exec",
        "//src/mongo/db/repl:replica_set_messages",
        "//src/mongo/db/s:query_analysis_writer",
        "//src/mongo/db/session:session_catalog_mongod",
        "//src/mongo/db/shard_role:resource_yielders",
        "//src/mongo/db/shard_role/ddl:coll_mod_command_idl",
        "//src/mongo/db/shard_role/ddl:index_commands_idl",
        "//src/mongo/db/shard_role/ddl:rename_collection_idl",
        "//src/mongo/db/shard_role/lock_manager",
        "//src/mongo/db/shard_role/lock_manager:exception_util",
        "//src/mongo/db/shard_role/lock_manager:lock_info_command",
        "//src/mongo/db/shard_role/shard_catalog:catalog_helpers",
        "//src/mongo/db/shard_role/shard_catalog:database_holder",
        "//src/mongo/db/shard_role/shard_catalog:raw_data_operation",
        "//src/mongo/db/shard_role/shard_catalog:validate_db_metadata_command",
        "//src/mongo/db/stats:counters",
        "//src/mongo/db/stats:server_read_concern_write_concern_metrics",
        "//src/mongo/db/stats:top",
        "//src/mongo/db/storage:storage_engine_common",
        "//src/mongo/db/storage:storage_options",
        "//src/mongo/db/timeseries:catalog_helper",
        "//src/mongo/db/timeseries:collection_pre_conditions_util",
        "//src/mongo/db/timeseries:timeseries_collmod",
        "//src/mongo/db/timeseries:timeseries_conversion_util",
        "//src/mongo/db/timeseries:timeseries_options",
        "//src/mongo/db/timeseries:timeseries_write_util",
        "//src/mongo/db/transaction",
        "//src/mongo/db/transaction:transaction_operations",
        "//src/mongo/db/validate:collection_validation",
        "//src/mongo/db/views:view_catalog_helpers",
        "//src/mongo/executor:async_request_executor",
        "//src/mongo/rpc:rewrite_state_change_errors",
        "//src/mongo/s:query_analysis_sampler",
        "//src/mongo/s:sharding_router_api",
        "//src/mongo/util:log_and_backoff",
        "//src/mongo/util/net:http_client",
    ],
)

# Commands that should only be present in mongod
mongo_cc_library(
    name = "mongod",
    srcs = [
        "apply_ops_cmd.cpp",
        "auto_compact.cpp",
        "collection_to_capped.cpp",
        "compact.cpp",
        "compact_gen",
        "dbhash.cpp",
        "filemd5_cmd.cpp",
        "fle2_cleanup_cmd.cpp",
        "fle2_compact_cmd.cpp",
        "internal_transactions_test_command_d.cpp",
        "oplog_application_checks.cpp",
        "oplog_note.cpp",
        "profile_cmd.cpp",
        "resize_oplog.cpp",
        "resize_oplog_gen",
        "rwc_defaults_commands.cpp",
        "set_feature_compatibility_version_command.cpp",
        "set_index_commit_quorum_command.cpp",
        "shutdown_d.cpp",
        "snapshot_management.cpp",
        "top_command.cpp",
        "txn_cmds.cpp",
        "user_management_commands.cpp",
        "vote_abort_index_build_command.cpp",
        "vote_commit_index_build_command.cpp",
        "vote_index_build_gen",
        "//src/mongo/db/commands/query_cmd:map_reduce_command.cpp",
        "//src/mongo/db/commands/server_status:read_write_concern_defaults_server_status.cpp",
        "//src/mongo/db/shard_role/ddl:internal_rename_if_options_and_indexes_match_cmd.cpp",
        "//src/mongo/db/shard_role/ddl:internal_rename_if_options_and_indexes_match_gen",
        "//src/mongo/db/topology/cluster_parameters:get_cluster_parameter_command.cpp",
        "//src/mongo/db/topology/cluster_parameters:set_cluster_parameter_command.cpp",
        "//src/mongo/db/topology/user_write_block:set_user_write_block_mode_command.cpp",
    ],
    deps = [
        "cluster_server_parameter_commands_invocation",
        "core",
        "create_command",
        "dbcheck_command",
        "kill_common",
        "mongod_fcv",
        "mongod_fsync",
        "profile_common",
        "rwc_defaults_commands",
        "servers",
        "set_cluster_parameter_impl",
        "set_feature_compatibility_version_idl",
        "set_index_commit_quorum_idl",
        "shutdown_idl",
        "standalone",
        "test_commands",
        "test_commands_enabled",
        "txn_cmd_request",
        "umc_commands_idl",
        "//src/mongo/client:clientdriver_minimal",
        "//src/mongo/crypto:fle_crypto",
        "//src/mongo/db:change_stream_options_manager",
        "//src/mongo/db:change_stream_pre_images_collection_manager",
        "//src/mongo/db:cluster_transaction_api",
        "//src/mongo/db:commands",
        "//src/mongo/db:curop_failpoint_helpers",
        "//src/mongo/db:dbhelpers",
        "//src/mongo/db:fle_crud_mongod",
        "//src/mongo/db:index_key_validate",
        "//src/mongo/db:local_executor",
        "//src/mongo/db:multitenancy",
        "//src/mongo/db:profile_collection",
        "//src/mongo/db:rw_concern_d",
        "//src/mongo/db:server_base",
        "//src/mongo/db/auth",
        "//src/mongo/db/auth:address_restriction",
        "//src/mongo/db/auth:auth_options",
        "//src/mongo/db/auth:auth_umc",
        "//src/mongo/db/auth:authprivilege",
        "//src/mongo/db/auth:builtin_roles",
        "//src/mongo/db/auth:sasl_options",
        "//src/mongo/db/auth:user",
        "//src/mongo/db/auth:user_document_parser",
        "//src/mongo/db/commands/query_cmd:map_reduce_agg",
        "//src/mongo/db/global_catalog/ddl:sharding_catalog_manager",
        "//src/mongo/db/index_builds:index_builds_coordinator",
        "//src/mongo/db/pipeline",
        "//src/mongo/db/pipeline/process_interface:mongo_process_interface",
        "//src/mongo/db/repl:oplog",
        "//src/mongo/db/repl:repl_coordinator_interface",
        "//src/mongo/db/repl:repl_server_parameters",
        "//src/mongo/db/repl:replica_set_messages",
        "//src/mongo/db/repl/dbcheck",
        "//src/mongo/db/rss:replicated_storage_service",
        "//src/mongo/db/s:sharding_commands_d",
        "//src/mongo/db/s:transaction_coordinator",
        "//src/mongo/db/shard_role/ddl:coll_mod_command_idl",
        "//src/mongo/db/shard_role/ddl:index_commands_idl",
        "//src/mongo/db/shard_role/shard_catalog:catalog_control",
        "//src/mongo/db/shard_role/shard_catalog:catalog_helpers",
        "//src/mongo/db/shard_role/shard_catalog:catalog_impl",
        "//src/mongo/db/shard_role/shard_catalog:database_holder",
        "//src/mongo/db/stats:top",
        "//src/mongo/db/timeseries:timeseries_conversion_util",
        "//src/mongo/db/topology/user_write_block:set_user_write_block_mode_idl",
        "//src/mongo/db/topology/user_write_block:user_writes_recoverable_critical_section",
        "//src/mongo/db/transaction:transaction_api",
        "//src/mongo/executor:inline_executor",
        "//src/mongo/util:progress_meter",
        "//src/mongo/util/net:ssl_manager",
    ] + select({
        "//bazel/config:enterprise_feature_live_import_enabled": [
            "//src/mongo/db/modules/enterprise/src/live_import/commands:export_collection_command",
            "//src/mongo/db/modules/enterprise/src/live_import/commands:import_collection_command",
            "//src/mongo/db/modules/enterprise/src/live_import/commands:vote_commit_import_collection_command",
        ],
        "//conditions:default": [],
    }),
)

mongo_cc_unit_test(
    name = "async_command_execution_test",
    srcs = [
        "async_command_execution_test.cpp",
    ],
    tags = ["mongo_unittest_first_group"],
    deps = [
        "//src/mongo:base",
        "//src/mongo/db:commands",
        "//src/mongo/db:service_context_test_fixture",
        "//src/mongo/db/auth:authmocks",
        "//src/mongo/db/auth:authorization_manager_global",
        "//src/mongo/db/commands:standalone",
        "//src/mongo/db/shard_role:service_context_non_d",
        "//src/mongo/db/sharding_environment:unittest_noop_sharding_initialization_mongod",
        "//src/mongo/util:version_impl",
    ],
)

mongo_cc_unit_test(
    name = "command_mirroring_test",
    srcs = [
        "command_mirroring_test.cpp",
    ],
    tags = ["mongo_unittest_seventh_group"],
    deps = [
        ":standalone",
        "//src/mongo:base",
        "//src/mongo/db:commands",
        "//src/mongo/db/auth:authmocks",
        "//src/mongo/db/auth:authorization_manager_global",
        "//src/mongo/db/shard_role:service_context_non_d",
        "//src/mongo/db/sharding_environment:unittest_noop_sharding_initialization_mongod",
        "//src/mongo/unittest",
    ],
)

mongo_cc_unit_test(
    name = "db_commands_test",
    srcs = [
        "parse_log_component_settings_test.cpp",
        "profile_cmd_test.cpp",
        "set_profiling_filter_globally_cmd_test.cpp",
        "//src/mongo/db/commands/query_cmd:aggregation_execution_state_test.cpp",
        "//src/mongo/db/commands/query_cmd:explain_test.cpp",
        "//src/mongo/db/commands/query_cmd:external_data_source_commands_test.cpp",
        "//src/mongo/db/commands/query_cmd:index_filter_commands_test.cpp",
        "//src/mongo/db/commands/query_cmd:plan_cache_commands_test.cpp",
        "//src/mongo/db/commands/query_cmd:run_aggregate_test.cpp",
        "//src/mongo/db/commands/query_cmd:write_commands_test.cpp",
        "//src/mongo/db/commands/server_status:server_status_command_test.cpp",
        "//src/mongo/db/commands/server_status:server_status_metric_test.cpp",
        "//src/mongo/db/shard_role/ddl:create_command_test.cpp",
        "//src/mongo/db/shard_role/ddl:list_collections_filter_test.cpp",
        "//src/mongo/db/topology/cluster_parameters:set_cluster_parameter_invocation_test.cpp",
    ],
    srcs_select = [{
        "//bazel/config:js_engine_none": [],
        "//bazel/config:js_engine_mozjs": [
            "//src/mongo/db/commands/query_cmd:mr_test.cpp",
        ],
    }],
    tags = ["mongo_unittest_fourth_group"],
    deps = [
        ":cluster_server_parameter_commands_invocation",
        ":core",
        ":create_command",
        ":dbcheck_command",
        ":list_collections_filter",
        ":mongod",
        ":profile_cmd_test_utils",
        ":profile_common",
        ":servers",
        ":standalone",
        "//src/mongo/crypto:aead_encryption",
        "//src/mongo/crypto:encrypted_field_config",
        "//src/mongo/crypto:fle_crypto",
        "//src/mongo/db:dbdirectclient",
        "//src/mongo/db:fle_crud",
        "//src/mongo/db:fle_mocks",
        "//src/mongo/db:multitenancy",
        "//src/mongo/db:query_exec",
        "//src/mongo/db:service_context_d_test_fixture",
        "//src/mongo/db/auth:authmocks",
        "//src/mongo/db/collection_crud",
        "//src/mongo/db/commands/server_status:server_status_core",
        "//src/mongo/db/index_builds:index_builds_coordinator",
        "//src/mongo/db/memory_tracking",
        "//src/mongo/db/op_observer",
        "//src/mongo/db/pipeline:document_source_mock",
        "//src/mongo/db/query:query_planner",
        "//src/mongo/db/query:query_test_service_context",
        "//src/mongo/db/query/client_cursor",
        "//src/mongo/db/query/virtual_collection",
        "//src/mongo/db/repl:replmocks",
        "//src/mongo/db/repl:storage_interface_impl",
        "//src/mongo/db/repl/dbcheck:dbcheck_test_fixture",
        "//src/mongo/db/repl/dbcheck:health_log",
        "//src/mongo/db/shard_role",
        "//src/mongo/db/shard_role/lock_manager:exception_util",
        "//src/mongo/db/shard_role/shard_catalog:catalog_helpers",
        "//src/mongo/db/shard_role/shard_catalog:catalog_test_fixture",
        "//src/mongo/db/sharding_environment:shard_server_test_fixture",
        "//src/mongo/db/storage:record_store_base",
        "//src/mongo/idl:idl_parser",
        "//src/mongo/shell:kms_idl",
        "//src/mongo/util:version_impl",
    ],
)

mongo_cc_unit_test(
    name = "create_indexes_command_test",
    srcs = [
        "create_indexes_test.cpp",
    ],
    tags = [
        "mongo_unittest_fifth_group",
        "server-index-builds",
    ],
    deps = [
        "//src/mongo/db:dbdirectclient",
        "//src/mongo/db/repl:storage_interface_impl",
        "//src/mongo/db/shard_role/shard_catalog:catalog_test_fixture",
    ],
)

mongo_cc_unit_test(
    name = "dbcheck_and_compact_test",
    srcs = [
        "dbcheck_command_test.cpp",
        "fle_compact_test.cpp",
    ],
    tags = [
        "mongo_unittest_eighth_group",
        "server-integration-smoke",
    ],
    deps = [
        ":cluster_server_parameter_commands_invocation",
        ":core",
        ":create_command",
        ":dbcheck_command",
        ":list_collections_filter",
        ":mongod",
        ":profile_cmd_test_utils",
        ":profile_common",
        ":servers",
        ":standalone",
        "//src/mongo/crypto:aead_encryption",
        "//src/mongo/crypto:encrypted_field_config",
        "//src/mongo/crypto:fle_crypto",
        "//src/mongo/db:dbdirectclient",
        "//src/mongo/db:fle_crud",
        "//src/mongo/db:fle_mocks",
        "//src/mongo/db:multitenancy",
        "//src/mongo/db:query_exec",
        "//src/mongo/db:service_context_d_test_fixture",
        "//src/mongo/db/auth:authmocks",
        "//src/mongo/db/collection_crud",
        "//src/mongo/db/commands/server_status:server_status_core",
        "//src/mongo/db/memory_tracking",
        "//src/mongo/db/op_observer",
        "//src/mongo/db/repl:replmocks",
        "//src/mongo/db/repl:storage_interface_impl",
        "//src/mongo/db/repl/dbcheck:dbcheck_test_fixture",
        "//src/mongo/db/repl/dbcheck:health_log",
        "//src/mongo/db/shard_role",
        "//src/mongo/db/shard_role/shard_catalog:catalog_test_fixture",
        "//src/mongo/shell:kms_idl",
        "//src/mongo/util:version_impl",
    ],
)

mongo_cc_unit_test(
    name = "mongod_fcv_test",
    srcs = [
        "feature_compatibility_version_test.cpp",
    ],
    tags = ["mongo_unittest_seventh_group"],
    deps = [
        "mongod_fcv",
        "//src/mongo/db/shard_role/shard_catalog:catalog_test_fixture",
    ],
)
